<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "acm/front";
        var now0=stdTime([[${now0}]]);
        $(function() {
            var options = {
                url: prefix + "/clist",
                modalName: "竞赛与考试",
				search: false,
		        showExport: false,
		        showRefresh:false,
				showColumns:false,
				showToggle:false,
				sortName: "startTime",    // 排序列名称
                sortOrder: "desc",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id',
					title : '赛事编号',
					visible: false
				},
				{
					field : 'title', 
					title : '比赛名称',
					sortable: true
				},
				{
					field : 'startTime', 
					title : '开始时间',
					sortable: true
				},
				{
					field : 'endTime', 
					title : '结束时间',
					sortable: true
				},
				{
					field : 'description', 
					title : '赛事说明',
					sortable: true
				},
				{
					field : 'startReg', 
					title : '开始注册时间',
					sortable: true
				},
				{
					field : 'endReg', 
					title : '结束注册时间',
					sortable: true
				},

		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	var startReg=stdTime(row.startReg);
		            	var endReg=stdTime(row.endReg);
		            	var startTime=stdTime(row.startTime);
		            	if(now0>=startReg && now0<=endReg)
		            		actions.push('<a class="btn btn-success btn-xs " href="#" onclick="regcontest(\'' +row.id + '\')"><i class="fa fa-cc"></i>注册参赛</a> ');
		            	else if (now0>endReg)
		            		actions.push('<a class="btn btn-default btn-xs " href="#" ><i class="fa fa-stop"></i>已结束</a> ');
		            	else if (now0<startReg)
		            		actions.push('<a class="btn btn-default btn-xs " href="#" ><i class="fa fa-stop"></i>未开始</a> ');
	
		            	if(now0>=startReg)
		            		actions.push('<a class="btn btn-success btn-xs " href="#" onclick="look(\'' +row.id + '\')"><i class="fa fa-bar-chart"></i>排名</a> ');
				
		            	return actions.join('');
		            }
		        }]
            };
            $.table.init(options);

});
function regcontest(cid)
{
	$.operate.get(ctx + 'acm/attend/add/'+cid ,function(){
		$.modal.openTab("竞赛与考试题目",ctx + 'acm/front/contestP?cid='+cid);
	})	
}
function look(cid)
{
	$.modal.openTab("竞赛与考试排名",ctx + 'acm/front/rankio?cid='+cid);
}
    </script>
</body>
</html>